<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>AMBHAS: /home/tomer/svn/ambhas/ambhas/soil_texture.py Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">AMBHAS
   
   </div>
   
  </td>
  
  
  
   
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('soil__texture_8py.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">soil_texture.py</div>  </div>
</div><!--header-->
<div class="contents">
<a href="soil__texture_8py.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="namespaceambhas_1_1soil__texture.html">00001</a> <span class="comment"># -*- coding: utf-8 -*-</span>
<a name="l00002"></a>00002 <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00003"></a>00003 <span class="stringliteral">Created on Tue Nov  1 18:57:30 2011</span>
<a name="l00004"></a>00004 <span class="stringliteral"></span>
<a name="l00005"></a>00005 <span class="stringliteral">@author: Sat Kumar Tomer</span>
<a name="l00006"></a>00006 <span class="stringliteral">@website: www.ambhas.com</span>
<a name="l00007"></a>00007 <span class="stringliteral">@email: satkumartomer@gmail.com</span>
<a name="l00008"></a>00008 <span class="stringliteral"></span>
<a name="l00009"></a>00009 <span class="stringliteral">http://nowlin.css.msu.edu/software/triangle_form.html</span>
<a name="l00010"></a>00010 <span class="stringliteral">http://ag.arizona.edu/research/rosetta/rosetta.html#download</span>
<a name="l00011"></a>00011 <span class="stringliteral"></span>
<a name="l00012"></a>00012 <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00013"></a>00013 <span class="keyword">import</span> matplotlib.nxutils <span class="keyword">as</span> nx
<a name="l00014"></a>00014 <span class="keyword">import</span> numpy <span class="keyword">as</span> np
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 
<a name="l00017"></a><a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html">00017</a> <span class="keyword">class </span><a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html">soil_texture</a>:
<a name="l00018"></a>00018     <span class="stringliteral">&quot;&quot;&quot;</span>
<a name="l00019"></a>00019 <span class="stringliteral">    Input:</span>
<a name="l00020"></a>00020 <span class="stringliteral">        sand</span>
<a name="l00021"></a>00021 <span class="stringliteral">        clay</span>
<a name="l00022"></a>00022 <span class="stringliteral">    output:</span>
<a name="l00023"></a>00023 <span class="stringliteral">        </span>
<a name="l00024"></a>00024 <span class="stringliteral">    &quot;&quot;&quot;</span>
<a name="l00025"></a><a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a34f87e4d96a4ba02a6b8b5fd3297fa2f">00025</a>     <span class="keyword">def </span><a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#af970c1dbcd774844847162b58711be29">__init__</a>(self, sand, clay):
<a name="l00026"></a>00026         self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#ab73d3f3a9de1848b65413c09ea4f041f">sand</a> = sand
<a name="l00027"></a>00027         self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a39f0630ec52e869f01c439011ebd31a0">clay</a> = clay
<a name="l00028"></a>00028         
<a name="l00029"></a>00029     
<a name="l00030"></a>00030         soil_names = [<span class="stringliteral">&#39;silty_loam&#39;</span>, <span class="stringliteral">&#39;sand&#39;</span>, <span class="stringliteral">&#39;silty_clay_loam&#39;</span>, <span class="stringliteral">&#39;loam&#39;</span>, <span class="stringliteral">&#39;clay_loam&#39;</span>,
<a name="l00031"></a>00031                       <span class="stringliteral">&#39;sandy_loam&#39;</span>, <span class="stringliteral">&#39;silty_clay&#39;</span>, <span class="stringliteral">&#39;sandy_clay_loam&#39;</span>, <span class="stringliteral">&#39;loamy_sand &#39;</span>,
<a name="l00032"></a>00032                       <span class="stringliteral">&#39;clay&#39;</span>, <span class="stringliteral">&#39;silt&#39;</span>, <span class="stringliteral">&#39;sandy_clay&#39;</span>]
<a name="l00033"></a>00033         
<a name="l00034"></a>00034         <span class="comment"># sand, clay</span>
<a name="l00035"></a>00035         t0 = np.array([ [0,12], [0,27], [23,27], [50,0], [20,0], [8,12]], float)
<a name="l00036"></a>00036         t1 = np.array([ [85,0], [90,10], [100,0]], float)
<a name="l00037"></a>00037         t2 = np.array([ [0,27], [0,40], [20,40], [20,27]], float) 
<a name="l00038"></a>00038         t3 = np.array([ [43,7], [23,27], [45,27], [52,20], [52,7]], float) 
<a name="l00039"></a>00039         t4 = np.array([ [20,27], [20,40], [45,40], [45,27]], float)  
<a name="l00040"></a>00040         t5 = np.array([ [50,0], [43,7], [52,7], [52,20], [80,20], [85,15], [70,0]], float)
<a name="l00041"></a>00041         t6 = np.array([ [0,40], [0,60], [20,40]], float) 
<a name="l00042"></a>00042         t7 = np.array([ [52,20], [45,27], [45,35], [65,35], [80,20]], float)
<a name="l00043"></a>00043         t8 = np.array([ [70,0], [85,15], [90,10], [85,0]], float)
<a name="l00044"></a>00044         t9 = np.array([ [20,40], [0,60], [0,100], [45,55], [45,40]], float) 
<a name="l00045"></a>00045         t10 = np.array([ [0,0], [0,12], [8,12], [20,0]], float) 
<a name="l00046"></a>00046         t11 = np.array([ [45,35], [45,55], [65,35]], float)
<a name="l00047"></a>00047         
<a name="l00048"></a>00048               
<a name="l00049"></a>00049         <span class="comment">#N θr θs log(α) log(n) Ks Ko L</span>
<a name="l00050"></a>00050         <span class="comment">#-- θr -- cm3/cm3</span>
<a name="l00051"></a>00051         <span class="comment">#-- θs -- cm3/cm3</span>
<a name="l00052"></a>00052         <span class="comment">#-- log(α) --  log10(1/cm)</span>
<a name="l00053"></a>00053         <span class="comment">#-- log(n) --  log10</span>
<a name="l00054"></a>00054         <span class="comment">#-- Ks --  log(cm/day)</span>
<a name="l00055"></a>00055         <span class="comment">#-- Ko --  log(cm/day)</span>
<a name="l00056"></a>00056         <span class="comment">#-- L -- </span>
<a name="l00057"></a>00057         
<a name="l00058"></a>00058         shp = [[330, 0.065, 0.073, 0.439, 0.093, -2.296, 0.57, 0.221, 0.14, 1.261, 0.74, 0.243, 0.26,  0.365, 1.42],
<a name="l00059"></a>00059                [308, 0.053, 0.029, 0.375, 0.055, -1.453, 0.25, 0.502, 0.18, 2.808, 0.59, 1.389, 0.24, -0.930, 0.49],
<a name="l00060"></a>00060                [172, 0.090, 0.082, 0.482, 0.086, -2.076, 0.59, 0.182, 0.13, 1.046, 0.76, 0.349, 0.26, -0.156, 1.23],
<a name="l00061"></a>00061                [242, 0.061, 0.073, 0.399, 0.098, -1.954, 0.73, 0.168, 0.13, 1.081, 0.92, 0.568, 0.21, -0.371, 0.84],
<a name="l00062"></a>00062                [140, 0.079, 0.076, 0.442, 0.079, -1.801, 0.69, 0.151, 0.12, 0.913, 1.09, 0.699, 0.23, -0.763, 0.90],
<a name="l00063"></a>00063                [476, 0.039, 0.054, 0.387, 0.085, -1.574, 0.56, 0.161, 0.11, 1.583, 0.66, 1.190, 0.21, -0.861, 0.73],
<a name="l00064"></a>00064                [28,  0.111, 0.119, 0.481, 0.080, -1.790, 0.64, 0.121, 0.10, 0.983, 0.57, 0.501, 0.27, -1.287, 1.23],
<a name="l00065"></a>00065                [87,  0.063, 0.078, 0.384, 0.061, -1.676, 0.71, 0.124, 0.12, 1.120, 0.85, 0.841, 0.24, -1.280, 0.99],
<a name="l00066"></a>00066                [201, 0.049, 0.042, 0.390, 0.070, -1.459, 0.47, 0.242, 0.16, 2.022, 0.64, 1.386, 0.24, -0.874, 0.59],
<a name="l00067"></a>00067                [84,  0.098, 0.107, 0.459, 0.079, -1.825, 0.68, 0.098, 0.07, 1.169, 0.92, 0.472, 0.26,  1.561, 1.39],
<a name="l00068"></a>00068                [6,   0.050, 0.041, 0.489, 0.078, -2.182, 0.30, 0.225, 0.13, 1.641, 0.27, 0.524, 0.32,  0.624, 1.57],
<a name="l00069"></a>00069                [11,  0.117, 0.114, 0.385, 0.046, -1.476, 0.57, 0.082, 0.06, 1.055, 0.89, 0.637, 0.34, -3.665, 1.80]]
<a name="l00070"></a>00070         
<a name="l00071"></a>00071         <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(12):
<a name="l00072"></a>00072             exec(<span class="stringliteral">&quot;if nx.pnpoly(sand, clay, t0):tt=i&quot;</span>).replace(<span class="stringliteral">&#39;0&#39;</span>,str(i))
<a name="l00073"></a>00073     
<a name="l00074"></a>00074         <span class="keywordflow">if</span> sand+clay&lt;100:
<a name="l00075"></a>00075             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a7a68531cd16c4f38b4630a1450993efb">soil_type</a> = soil_names[tt]
<a name="l00076"></a>00076             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a92d9a4476a1b6f45d3a15d535ac8a0be">theta_r</a> = shp[tt][1]
<a name="l00077"></a>00077             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a34f87e4d96a4ba02a6b8b5fd3297fa2f">theta_s</a> = shp[tt][3]
<a name="l00078"></a>00078             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a8d98ef3277cfda42a697cf6546b029b2">alpha</a> = 10**shp[tt][5]*100
<a name="l00079"></a>00079             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a5758b042bd060a11e39f56988dc75f10">n</a> = 10**shp[tt][7]
<a name="l00080"></a>00080             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a83caa4f325b72bd6393859a585281061">ks</a>= np.exp(shp[tt][9])/100/86400
<a name="l00081"></a>00081             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a49604c0984385e3890613f733235b1c1">l</a>= shp[tt][13]
<a name="l00082"></a>00082         <span class="keywordflow">else</span>:
<a name="l00083"></a>00083             print(<span class="stringliteral">&quot;sand+clay is more than 100 percent&quot;</span>)
<a name="l00084"></a>00084             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a7a68531cd16c4f38b4630a1450993efb">soil_type</a> = np.nan
<a name="l00085"></a>00085             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a92d9a4476a1b6f45d3a15d535ac8a0be">theta_r</a> = np.nan
<a name="l00086"></a>00086             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a34f87e4d96a4ba02a6b8b5fd3297fa2f">theta_s</a> = np.nan
<a name="l00087"></a>00087             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a8d98ef3277cfda42a697cf6546b029b2">alpha</a> = np.nan
<a name="l00088"></a>00088             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a5758b042bd060a11e39f56988dc75f10">n</a> = np.nan
<a name="l00089"></a>00089             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a83caa4f325b72bd6393859a585281061">ks</a>= np.nan
<a name="l00090"></a>00090             self.<a class="code" href="classambhas_1_1soil__texture_1_1soil__texture.html#a49604c0984385e3890613f733235b1c1">l</a>= np.nan
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="soil__texture_8py.html">soil_texture.py</a>      </li>

    <li class="footer">Generated on Sat Jul 21 2012 12:26:08 for AMBHAS by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
